home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / gedit-2 / plugins / externaltools / outputpanel.pyc (.txt) < prev   
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  3.8 KB  |  89 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. __all__ = ('OutputPanel', 'UniqueById')
  5. import gtk
  6. import gedit
  7. import pango
  8. import gobject
  9. import os
  10. from weakref import WeakKeyDictionary
  11. from capture import *
  12.  
  13. class UniqueById:
  14.     __shared_state = WeakKeyDictionary()
  15.     
  16.     def __init__(self, i):
  17.         if i in self.__class__._UniqueById__shared_state:
  18.             self.__dict__ = self.__class__._UniqueById__shared_state[i]
  19.             return True
  20.         self.__class__._UniqueById__shared_state[i] = self.__dict__
  21.         return False
  22.  
  23.     
  24.     def states(self):
  25.         return self.__class__._UniqueById__shared_state
  26.  
  27.  
  28.  
  29. class OutputPanel(UniqueById):
  30.     
  31.     def __init__(self, datadir, window):
  32.         if UniqueById.__init__(self, window):
  33.             return None
  34.         callbacks = {
  35.             'on_stop_clicked': self.on_stop_clicked }
  36.         self.window = window
  37.         self.ui = gtk.Builder()
  38.         self.ui.add_from_file(os.path.join(datadir, 'ui', 'outputpanel.ui'))
  39.         self.ui.connect_signals(callbacks)
  40.         self.panel = self['output-panel']
  41.         self['view'].modify_font(pango.FontDescription('Monospace'))
  42.         buffer = self['view'].get_buffer()
  43.         self.normal_tag = buffer.create_tag('normal')
  44.         self.error_tag = buffer.create_tag('error')
  45.         self.error_tag.set_property('foreground', 'red')
  46.         self.italic_tag = buffer.create_tag('italic')
  47.         self.italic_tag.set_property('style', pango.STYLE_OBLIQUE)
  48.         self.bold_tag = buffer.create_tag('bold')
  49.         self.bold_tag.set_property('weight', pango.WEIGHT_BOLD)
  50.         self.process = None
  51.  
  52.     
  53.     def __getitem__(self, key):
  54.         return self.ui.get_object(key)
  55.  
  56.     
  57.     def on_stop_clicked(self, widget, *args):
  58.         if self.process is not None:
  59.             self.write('\n' + _('Stopped.') + '\n', self.italic_tag)
  60.             self.process.stop(-1)
  61.         
  62.  
  63.     
  64.     def scroll_to_end(self):
  65.         iter = self['view'].get_buffer().get_end_iter()
  66.         self['view'].scroll_to_iter(iter, 0)
  67.         return False
  68.  
  69.     
  70.     def clear(self):
  71.         self['view'].get_buffer().set_text('')
  72.  
  73.     
  74.     def write(self, text, tag = None):
  75.         buffer = self['view'].get_buffer()
  76.         if tag is None:
  77.             buffer.insert(buffer.get_end_iter(), text)
  78.         else:
  79.             buffer.insert_with_tags(buffer.get_end_iter(), text, tag)
  80.         gobject.idle_add(self.scroll_to_end)
  81.  
  82.     
  83.     def show(self):
  84.         panel = self.window.get_bottom_panel()
  85.         panel.show()
  86.         panel.activate_item(self.panel)
  87.  
  88.  
  89.